save
Purpose
Saves a domain class instance to the database cascading updates to any child instances if required.Examples
def b = new Book(title:"The Shining")
b.save()
Description
The save method informs the persistence context that an instance should be saved or updated. The object will not be persisted immediately unless the flush argument is used:The save method returns null if validation failed and the instance was not saved and the instance itself if successful. This allows you to write code like the following:if( !b.save() ) {
b.errors.each {
println it
}
} Parameters:
validate (optional) - Set to false if validation should be skipped
flush (optional) - When set to true flushes the persistent context, hence persisting the object immediately